package com.ht.temp.service.impl;

import com.ht.temp.entity.DayReport;
import com.ht.temp.entity.MonthReport;
import com.ht.temp.mapper.MonthReportMapper;
import com.ht.temp.service.IMonthReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mayke_zhou
 * @since 2018-12-24
 */
@Service
@Transactional
public class MonthReportServiceImpl extends ServiceImpl<MonthReportMapper, MonthReport> implements IMonthReportService {
    @Autowired
    private  MonthReportMapper monthReportMapper;

    @Override
    public int deleteByPrimaryKey(Integer monthId) {
        return monthReportMapper.deleteByPrimaryKey(monthId);
    }

    @Override
    public int insertSelective(MonthReport record) {
        return monthReportMapper.insertSelective(record);
    }

    @Override
    public MonthReport selectByPrimaryKey(Integer monthId) {
        return monthReportMapper.selectByPrimaryKey(monthId);
    }

    @Override
    public List<MonthReport> getMonthReportByYear(Integer deviceId, String startTime, String endTime) {
        System.out.println(startTime.substring(0,startTime.length()-9)+"/"+endTime.substring(0,startTime.length()-9));
        String sTime = startTime.substring(0,startTime.length()-9);
        String eTime = endTime.substring(0,startTime.length()-9);
        return monthReportMapper.selectMonthReportByYear(sTime,eTime,deviceId);
    }

    @Override
    public List<MonthReport> selectByMonthReport(MonthReport report) {
        return monthReportMapper.selectByMonthReport(report);
    }

    @Override
    public List<DayReport> selectByDayReport() {
        return null;
    }

    @Override
    public List<MonthReport> selectYearReport(String searchYear, Integer deviceId) {
        searchYear=searchYear+"-01-01";
        return  monthReportMapper.selectYearReport(searchYear,deviceId);
    }
}
